#include "BuildState.h"

#include "Task.h"

namespace BroodWar
{
	namespace Addon
	{
		BuildState^ ConvertBuildState(BWSAL::BuildState state)
		{
			return gcnew BuildState(state);
		}

		BWSAL::BuildState ConvertBuildState(BuildState^ state)
		{
			return *(state->instance);
		}

		BuildState::BuildState(BWSAL::BuildState* state)
		{
			instance = state;
			dispose = false;
		}

		BuildState::BuildState(BWSAL::BuildState state)
		{
			instance = new BWSAL::BuildState(state);
			dispose = true;
		}
		
		BuildState::~BuildState()
		{
			if(dispose)
				delete instance;
		}
		
		BuildState::!BuildState()
		{
			if(dispose)
				delete instance;
		}
		
		BuildState::BuildState()
		{
			instance = new BWSAL::BuildState();
			dispose = true;
		}

		void BuildState::ContinueToTime(int time)
		{
			instance->continueToTime(time);
		}
		
		void BuildState::DoEvent(BuildEvent^ e)
		{
			instance->doEvent(ConvertBuildEvent(e));
		}
		
		void BuildState::UpdateWithCurrentGameState()
		{
			instance->updateWithCurrentGameState();
		}
		
		void BuildState::CreateUnclaimedBuildUnits()
		{
			instance->createUnclaimedBuildUnits();
		}
		
		int BuildState::GetNextTimeWithMinimumResources(int minerals, int gas)
		{
			return instance->getNextTimeWithMinimumResources(minerals, gas);
		}
		
		int BuildState::GetInsufficientTypes(BuildType buildType)
		{
			return instance->getInsufficientTypes(ConvertBuild(buildType));
		}
		
		bool BuildState::IsSupplyBlocked(Task^ t)
		{
			return instance->isSupplyBlocked(ConvertTask(t));
		}
		
		int BuildState::Time::get()
		{
			return instance->getTime();
		}
		
		double BuildState::Minerals::get()
		{
			return instance->getMinerals();
		}
		
		double BuildState::Gas::get()
		{
			return instance->getGas();
		}
		
		int BuildState::SupplyAvailable::get()
		{
			return instance->getSupplyAvailable();
		}
		
		int BuildState::SupplyTotal::get()
		{
			return instance->getSupplyTotal();
		}
		
		int BuildState::SupplyUsed::get()
		{
			return instance->getSupplyUsed();
		}

		int BuildState::MineralWorkers::get()
		{
			return instance->getMineralWorkers();
		}
		
		int BuildState::GasWorkers::get()
		{
			return instance->getGasWorkers();
		}
		
		unsigned int BuildState::CompletedBuildTypes::get()
		{
			return instance->getCompletedBuildTypes();
		}

		int BuildState::ReservedMinerals::get()
		{
			return instance->reservedMinerals;
		}
		
		void BuildState::ReservedMinerals::set(int reserve)
		{
			instance->reservedMinerals = reserve;
		}

		int BuildState::ReservedGas::get()
		{
			return instance->reservedGas;
		}
		
		void BuildState::ReservedGas::set(int reserve)
		{
			instance->reservedGas = reserve;
		}
	}
}
